package com.zhike.b2b.stock.impl;

import com.saas.biz.buyingclassMgr.Buyingclass;
import com.saas.biz.commen.Thumbnail;
import com.saas.biz.commen.CommGetId;
import com.saas.biz.commen.CommMethodMgr;
import com.saas.biz.companylevelMgr.CompanyLevelInfo;
import com.saas.biz.dao.stockorderDAO.StockorderDAO;
import com.saas.biz.dao.stockorderDAO.StockorderExt;
import com.saas.biz.scoreListMgr.ScoreListInfo;
import com.saas.sys.buffer.Buffers;
import com.saas.sys.exp.SaasApplicationException;
import com.saas.sys.log.Logger;
import com.zhike.b2b.dao.Dbtable;
import com.zhike.b2b.data.Attachinfo;

import java.io.PrintStream;
import java.sql.Connection;
import java.sql.SQLException;
import java.sql.Statement;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.HashMap;
import java.util.Iterator;
import java.util.StringTokenizer;

public class Stockorderinfo
{
  Dbtable tradeQuery = new Dbtable();
  Logger log = new Logger(this);
  Buffers inBuffer;
  Buffers outBuffer;
  ArrayList queryResult = new ArrayList();

  public void setTradeQuery(Dbtable paramDbtable)
  {
    this.tradeQuery = paramDbtable;
  }

  public Dbtable getTradeQuery()
  {
    return this.tradeQuery;
  }

  public void setOutBuffer(Buffers paramBuffers)
  {
    this.outBuffer = paramBuffers;
  }

  public Buffers getOutBuffer()
  {
    return this.outBuffer;
  }

  public ArrayList getQueryResult()
  {
    return this.queryResult;
  }

  public void setQueryResult(ArrayList paramArrayList)
  {
    this.queryResult = paramArrayList;
  }

  public ArrayList getBuyForDelete(int paramInt1, int paramInt2, String paramString1, String paramString2, String paramString3, String paramString4, String paramString5, String paramString6)
  {
    if (paramInt1 > 1)
      paramInt1 = (paramInt1 - 1) * paramInt2;
    else
      paramInt1 = 0;
    ArrayList localArrayList = new ArrayList();
    StockorderExt localStockorderExt = new StockorderExt();
    if (paramString3.equals(""))
      localStockorderExt.setParam(":VCOMPANY", "%");
    else
      localStockorderExt.setParam(":VCOMPANY", "%" + paramString3 + "%");
    if (paramString4.equals(""))
      localStockorderExt.setParam(":VUSER_NAME", "%");
    else
      localStockorderExt.setParam(":VUSER_NAME", "%" + paramString4 + "%");
    if (paramString5.equals(""))
      localStockorderExt.setParam(":VVALIDITY", "%");
    else
      localStockorderExt.setParam(":VVALIDITY", "%" + paramString5 + "%");
    if (paramString6.equals(""))
      localStockorderExt.setParam(":VTITLE", "%");
    else
      localStockorderExt.setParam(":VTITLE", "%" + paramString6 + "%");
    if ((paramString1.equals("")) && (paramString2.equals("")))
    {
      localArrayList = localStockorderExt.selByList("GET_NEWS", paramInt1, paramInt2);
    }
    else if ((paramString1.equals("")) && (!paramString2.equals("")))
    {
      localStockorderExt.setParam(":VEND", paramString2);
      localArrayList = localStockorderExt.selByList("GET_NEWS_ALL_END", paramInt1, paramInt2);
    }
    else if ((!paramString1.equals("")) && (paramString2.equals("")))
    {
      localStockorderExt.setParam(":VSTART", paramString1);
      localArrayList = localStockorderExt.selByList("GET_NEWS_ALL_START", paramInt1, paramInt2);
    }
    else if ((!paramString1.equals("")) && (!paramString2.equals("")))
    {
      localStockorderExt.setParam(":VEND", paramString2);
      localStockorderExt.setParam(":VSTART", paramString1);
      localArrayList = localStockorderExt.selByList("GET_NEWS_START_END", paramInt1, paramInt2);
    }
    return localArrayList;
  }

  public int getBuyForDelete(String paramString1, String paramString2, String paramString3, String paramString4, String paramString5, String paramString6)
  {
    ArrayList localArrayList = new ArrayList();
    StockorderExt localStockorderExt = new StockorderExt();
    if (paramString3.equals(""))
      localStockorderExt.setParam(":VCOMPANY", "%");
    else
      localStockorderExt.setParam(":VCOMPANY", "%" + paramString3 + "%");
    if (paramString4.equals(""))
      localStockorderExt.setParam(":VUSER_NAME", "%");
    else
      localStockorderExt.setParam(":VUSER_NAME", "%" + paramString4 + "%");
    if (paramString5.equals(""))
      localStockorderExt.setParam(":VVALIDITY", "%");
    else
      localStockorderExt.setParam(":VVALIDITY", "%" + paramString5 + "%");
    if (paramString6.equals(""))
      localStockorderExt.setParam(":VTITLE", "%");
    else
      localStockorderExt.setParam(":VTITLE", "%" + paramString6 + "%");
    if ((paramString1.equals("")) && (paramString2.equals("")))
    {
      localArrayList = localStockorderExt.selByList("GET_NEWS");
    }
    else if ((paramString1.equals("")) && (!paramString2.equals("")))
    {
      localStockorderExt.setParam(":VEND", paramString2);
      localArrayList = localStockorderExt.selByList("GET_NEWS_ALL_END");
    }
    else if ((!paramString1.equals("")) && (paramString2.equals("")))
    {
      localStockorderExt.setParam(":VSTART", paramString1);
      localArrayList = localStockorderExt.selByList("GET_NEWS_ALL_START");
    }
    else if ((!paramString1.equals("")) && (!paramString2.equals("")))
    {
      localStockorderExt.setParam(":VEND", paramString2);
      localStockorderExt.setParam(":VSTART", paramString1);
      localArrayList = localStockorderExt.selByList("GET_NEWS_START_END");
    }
    if ((localArrayList != null) && (localArrayList.size() > 0))
      return localArrayList.size();
    return 0;
  }

  public void addAddstockorder(Buffers paramBuffers)
    throws SaasApplicationException
  {
    this.outBuffer = paramBuffers;
    this.inBuffer = paramBuffers;
    this.log.LOG_INFO("进入addstockorder方法...");
    int i = -1;
    CommGetId localcommGetId = new CommGetId();
    String str1 = "";
    str1 = localcommGetId.getAutoTradeID(paramBuffers.getString("CUST_ID"), "buying", "buying_id");
    StockorderDAO localStockorderDAO = new StockorderDAO();
    localStockorderDAO.setBuying_name(paramBuffers.getString("buying_name"));
    localStockorderDAO.setClass_id(paramBuffers.getString("class_id"));
    Buyingclass localBuyingclass = new Buyingclass();
    String str2 = localBuyingclass.getClassNameById(paramBuffers.getString("class_id"));
    localStockorderDAO.setClass_name(str2);
    localStockorderDAO.setAttach_id(paramBuffers.getString("attach_id"));
    Attachinfo localAttachinfo = new Attachinfo();
    String str3 = localAttachinfo.getPicFilePath(paramBuffers.getString("attach_id"));
    if (str3.equals(""))
      localStockorderDAO.setAttach_tag(0);
    else
      localStockorderDAO.setAttach_tag(1);
    String str4 = "";
    if (paramBuffers.getString("validity").equals("0"))
      str4 = new CommGetId().getCheck(paramBuffers.getString("SESSION_CUST_ID"), "buying_check");
    else
      str4 = paramBuffers.getString("validity");
    localStockorderDAO.setValidity(str4);
    localStockorderDAO.setStart_date(paramBuffers.getString("start_date"));
    localStockorderDAO.setEnd_date(paramBuffers.getString("end_date"));
    localStockorderDAO.setBuying_site(paramBuffers.getString("buying_site"));
    localStockorderDAO.setBuying_desc(paramBuffers.getString("buying_desc"));
    localStockorderDAO.setKeywords(paramBuffers.getString("keywords"));
    localStockorderDAO.setExpect_prices(paramBuffers.getString("expect_prices"));
    localStockorderDAO.setMoneytype(paramBuffers.getString("moneytype"));
    localStockorderDAO.setBuying_num(paramBuffers.getString("buying_num"));
    localStockorderDAO.setProduct_spec_req(paramBuffers.getString("product_spec_req"));
    localStockorderDAO.setPack_type(paramBuffers.getString("pack_type"));
    localStockorderDAO.setDelivery(paramBuffers.getString("delivery"));
    localStockorderDAO.setCertify_req(paramBuffers.getString("certify_req"));
    localStockorderDAO.setLogistics(paramBuffers.getString("logistics"));
    localStockorderDAO.setCust_id(paramBuffers.getString("cust_id"));
    localStockorderDAO.setOper_user(paramBuffers.getString("oper_user"));
    localStockorderDAO.setPublish_user_id(paramBuffers.getString("oper_user"));
    localStockorderDAO.setBuying_unit(paramBuffers.getString("BUYING_UNIT"));
    localStockorderDAO.setBuying_id(str1);
    try
    {
      i = addStockorderinfo(localStockorderDAO, paramBuffers);
    }
    catch (SaasApplicationException localSaasApplicationException)
    {
      this.log.LOG_INFO(localSaasApplicationException.getMessage());
    }
    if (i != 0)
    {
      this.outBuffer.setInt("RESULT_CODE", -1);
      this.outBuffer.setString("RESULT_INFO", "业务处理失败！");
    }
    else
    {
      this.outBuffer.setInt("RESULT_CODE", 0);
      this.outBuffer.setString("RESULT_INFO", "业务处理成功！");
    }
    String str5 = paramBuffers.getString("TRADE_TYPE_CODE");
    log.LOG_DEBUG("trade_type_code========================" + str5);
    String str6 = new ScoreListInfo().getOperName(str5);
    String str7 = new CompanyLevelInfo().getLevelId(paramBuffers.getString("CUST_ID"));
    String str8 = new CommGetId().getLevel(str7, "buying_check");
    log.LOG_DEBUG("执行积分操作---------------------------------------------------------------");
    log.LOG_DEBUG("level_id-----------------------------------------------------------------" + str7);
    log.LOG_DEBUG("buying_check---------------------------------------------------------------" + str8);
    log.LOG_DEBUG("validity---------------------------------------------------------------" + str4);
    if ((str4.equals("1")) && (str8.equals("1")))
    {
      this.outBuffer.setString("BUILD", "1");
      this.outBuffer.setString("TABLENAME", "buying");
      this.outBuffer.setString("ID", str1);
      this.outBuffer.setString("OPER_NAME", str6);
    }
    this.log.LOG_INFO("退出addstockorder方法...");
  }

  public int addStockorderinfo(StockorderDAO paramStockorderDAO, Buffers paramBuffers)
    throws SaasApplicationException
  {
    StockorderExt localStockorderExt = new StockorderExt();
    localStockorderExt.setParam(":VBUYING_NAME", paramStockorderDAO.getBuying_name());
    localStockorderExt.setParam(":VCLASS_ID", paramStockorderDAO.getClass_id());
    localStockorderExt.setParam(":VATTACH_ID", paramStockorderDAO.getAttach_id());
    localStockorderExt.setParam(":VSTART_DATE", paramStockorderDAO.getStart_date());
    localStockorderExt.setParam(":VEND_DATE", paramStockorderDAO.getEnd_date());
    localStockorderExt.setParam(":VBUYING_SITE", paramStockorderDAO.getBuying_site());
    localStockorderExt.setParam(":VBUYING_DESC", paramStockorderDAO.getBuying_desc());
    localStockorderExt.setParam(":VKEYWORDS", paramStockorderDAO.getKeywords());
    localStockorderExt.setParam(":VEXPECT_PRICES", paramStockorderDAO.getExpect_prices());
    localStockorderExt.setParam(":VMONEYTYPE", paramStockorderDAO.getMoneytype());
    localStockorderExt.setParam(":VBUYING_NUM", paramStockorderDAO.getBuying_num());
    localStockorderExt.setParam(":VPRODUCT_SPEC_REQ", paramStockorderDAO.getProduct_spec_req());
    localStockorderExt.setParam(":VPACK_TYPE", paramStockorderDAO.getPack_type());
    localStockorderExt.setParam(":VDELIVERY", paramStockorderDAO.getDelivery());
    localStockorderExt.setParam(":VCERTIFY_REQ", paramStockorderDAO.getCertify_req());
    localStockorderExt.setParam(":VLOGISTICS", paramStockorderDAO.getLogistics());
    localStockorderExt.setParam(":VATTACH_TAG", Integer.valueOf(paramStockorderDAO.getAttach_tag()));
    localStockorderExt.setParam(":VCLASS_NAME", paramStockorderDAO.getClass_name());
    localStockorderExt.setParam(":VBUYING_ID", paramStockorderDAO.getBuying_id());
    localStockorderExt.setParam(":VCUST_ID", paramStockorderDAO.getCust_id());
    localStockorderExt.setParam(":VPUBLISH_USER_ID", paramStockorderDAO.getPublish_user_id());
    localStockorderExt.setParam(":VOPER_USER", paramStockorderDAO.getOper_user());
    localStockorderExt.setParam(":VVALIDITY", paramStockorderDAO.getValidity());
    localStockorderExt.setParam(":VBUYING_UNIT", paramStockorderDAO.getBuying_unit());
    String str = paramBuffers.getString("BIG_IMG");
    if ((str != null) && (!str.equals("")))
      new Thumbnail().creatThumbnail("buy", str);
    this.tradeQuery.executeBy(localStockorderExt.insBy("INS_BY_ALL"));
    this.outBuffer.setString("ROOT_ID", paramStockorderDAO.getBuying_id());
    return 0;
  }

  public void upstockorder(Buffers paramBuffers)
    throws SaasApplicationException
  {
    this.outBuffer = paramBuffers;
    this.inBuffer = paramBuffers;
    this.log.LOG_INFO("进入addstockorder方法...");
    int i = -1;
    StockorderDAO localStockorderDAO = new StockorderDAO();
    localStockorderDAO.setBuying_name(paramBuffers.getString("buying_name"));
    localStockorderDAO.setClass_id(paramBuffers.getString("class_id"));
    Buyingclass localBuyingclass = new Buyingclass();
    String str1 = localBuyingclass.getClassNameById(paramBuffers.getString("class_id"));
    localStockorderDAO.setClass_name(str1);
    localStockorderDAO.setAttach_id(paramBuffers.getString("attach_id"));
    Attachinfo localAttachinfo = new Attachinfo();
    String str2 = localAttachinfo.getPicFilePath(paramBuffers.getString("attach_id"));
    if (str2.equals(""))
      localStockorderDAO.setAttach_tag(0);
    else
      localStockorderDAO.setAttach_tag(1);
    String str3 = "";
    if (paramBuffers.getString("validity").equals("0"))
      str3 = new CommGetId().getCheck(paramBuffers.getString("SESSION_CUST_ID"), "buying_check");
    else
      str3 = paramBuffers.getString("validity");
    localStockorderDAO.setValidity(str3);
    localStockorderDAO.setStart_date(paramBuffers.getString("start_date"));
    localStockorderDAO.setEnd_date(paramBuffers.getString("end_date"));
    localStockorderDAO.setBuying_site(paramBuffers.getString("buying_site"));
    localStockorderDAO.setBuying_desc(paramBuffers.getString("buying_desc"));
    localStockorderDAO.setKeywords(paramBuffers.getString("keywords"));
    localStockorderDAO.setExpect_prices(paramBuffers.getString("expect_prices"));
    localStockorderDAO.setMoneytype(paramBuffers.getString("moneytype"));
    localStockorderDAO.setBuying_num(paramBuffers.getString("buying_num"));
    localStockorderDAO.setProduct_spec_req(paramBuffers.getString("product_spec_req"));
    localStockorderDAO.setPack_type(paramBuffers.getString("pack_type"));
    localStockorderDAO.setDelivery(paramBuffers.getString("delivery"));
    localStockorderDAO.setCertify_req(paramBuffers.getString("certify_req"));
    localStockorderDAO.setLogistics(paramBuffers.getString("logistics"));
    localStockorderDAO.setOper_user(paramBuffers.getString("oper_user"));
    localStockorderDAO.setBuying_id(paramBuffers.getString("buying_id"));
    localStockorderDAO.setCust_id(paramBuffers.getString("cust_id"));
    localStockorderDAO.setBuying_unit(paramBuffers.getString("buying_unit"));
    try
    {
      i = upStockorderinfo(localStockorderDAO, paramBuffers);
    }
    catch (SaasApplicationException localSaasApplicationException)
    {
      this.log.LOG_INFO(localSaasApplicationException.getMessage());
    }
    if (i != 0)
    {
      this.outBuffer.setInt("RESULT_CODE", -1);
      this.outBuffer.setString("RESULT_INFO", "业务处理失败！");
    }
    else
    {
      this.outBuffer.setInt("RESULT_CODE", 0);
      this.outBuffer.setString("RESULT_INFO", "业务处理成功！");
    }
    String str4 = paramBuffers.getString("TRADE_TYPE_CODE");
    log.LOG_DEBUG("trade_type_code========================" + str4);
    String str5 = new ScoreListInfo().getOperName(str4);
    String str6 = new CompanyLevelInfo().getLevelId(paramBuffers.getString("CUST_ID"));
    String str7 = new CommGetId().getLevel(str6, "buying_check");
    log.LOG_DEBUG("oper_name========================" + str5);
    log.LOG_DEBUG("level_id========================" + str6);
    log.LOG_DEBUG("buying_check========================" + str7);
    log.LOG_DEBUG("validity========================" + str3);
    if ((str3.equals("1")) && (str7.equals("1")))
    {
      this.outBuffer.setString("BUILD", "1");
      this.outBuffer.setString("TABLENAME", "buying");
      this.outBuffer.setString("ID", paramBuffers.getString("buying_id"));
      this.outBuffer.setString("OPER_NAME", str5);
    }
    this.log.LOG_INFO("退出addstockorder方法...");
  }

  public int upStockorderinfo(StockorderDAO paramStockorderDAO, Buffers paramBuffers)
    throws SaasApplicationException
  {
    StockorderExt localStockorderExt = new StockorderExt();
    localStockorderExt.setParam(":VVALIDITY", paramStockorderDAO.getValidity());
    localStockorderExt.setParam(":VBUYING_NAME", paramStockorderDAO.getBuying_name());
    localStockorderExt.setParam(":VCLASS_ID", paramStockorderDAO.getClass_id());
    localStockorderExt.setParam(":VATTACH_ID", paramStockorderDAO.getAttach_id());
    localStockorderExt.setParam(":VSTART_DATE", paramStockorderDAO.getStart_date());
    localStockorderExt.setParam(":VEND_DATE", paramStockorderDAO.getEnd_date());
    localStockorderExt.setParam(":VBUYING_SITE", paramStockorderDAO.getBuying_site());
    localStockorderExt.setParam(":VBUYING_DESC", paramStockorderDAO.getBuying_desc());
    localStockorderExt.setParam(":VKEYWORDS", paramStockorderDAO.getKeywords());
    localStockorderExt.setParam(":VEXPECT_PRICES", paramStockorderDAO.getExpect_prices());
    localStockorderExt.setParam(":VMONEYTYPE", paramStockorderDAO.getMoneytype());
    localStockorderExt.setParam(":VBUYING_NUM", paramStockorderDAO.getBuying_num());
    localStockorderExt.setParam(":VPRODUCT_SPEC_REQ", paramStockorderDAO.getProduct_spec_req());
    localStockorderExt.setParam(":VPACK_TYPE", paramStockorderDAO.getPack_type());
    localStockorderExt.setParam(":VDELIVERY", paramStockorderDAO.getDelivery());
    localStockorderExt.setParam(":VCERTIFY_REQ", paramStockorderDAO.getCertify_req());
    localStockorderExt.setParam(":VLOGISTICS", paramStockorderDAO.getLogistics());
    localStockorderExt.setParam(":VATTACH_TAG", Integer.valueOf(paramStockorderDAO.getAttach_tag()));
    localStockorderExt.setParam(":VCLASS_NAME", paramStockorderDAO.getClass_name());
    localStockorderExt.setParam(":VBUYING_ID", paramStockorderDAO.getBuying_id());
    localStockorderExt.setParam(":VCUST_ID", paramStockorderDAO.getCust_id());
    localStockorderExt.setParam(":VOPER_USER", paramStockorderDAO.getOper_user());
    localStockorderExt.setParam(":VBUYING_UNIT", paramStockorderDAO.getBuying_unit());
    String str = paramBuffers.getString("BIG_IMG");
    if ((str != null) && (!str.equals("")))
      new Thumbnail().creatThumbnail("buy", str);
    this.tradeQuery.executeBy(localStockorderExt.insBy("UPDATE_BY_ALL"));
    this.outBuffer.setString("ROOT_ID", paramStockorderDAO.getBuying_id());
    return 0;
  }

  public ArrayList genCustStockorder(String paramString)
  {
    ArrayList localArrayList = new ArrayList();
    StockorderExt localStockorderExt = new StockorderExt();
    localStockorderExt.setParam(":VBUYING_ID", paramString);
    localArrayList = localStockorderExt.selByList("SEL_order_buying_id");
    return localArrayList;
  }

  public void unload(Buffers paramBuffers)
  {
    this.log.LOG_INFO("进入unload方法...");
    this.outBuffer = paramBuffers;
    String str1 = "";
    String str2 = paramBuffers.getString("buying_id");
    log.LOG_DEBUG("=============================" + str2);
    String[] arrayOfString = str2.split(",");
    for (int i = 0; i < arrayOfString.length; i++)
    {
      str1 = arrayOfString[i];
      int j = -1;
      try
      {
        j = unload(str1);
      }
      catch (SaasApplicationException localSaasApplicationException)
      {
        this.log.LOG_INFO(localSaasApplicationException.getMessage());
      }
      if (j != 0)
      {
        this.outBuffer.setInt("RESULT_CODE", -1);
        this.outBuffer.setString("RESULT_INFO", "业务处理失败！");
      }
      else
      {
        this.outBuffer.setInt("RESULT_CODE", 0);
        this.outBuffer.setString("RESULT_INFO", "业务处理成功！");
      }
      this.log.LOG_INFO("退出delStockorder方法...");
    }
  }

  public int unload(String paramString)
    throws SaasApplicationException
  {
    log.LOG_DEBUG("=============================" + paramString);
    StockorderExt localStockorderExt = new StockorderExt();
    localStockorderExt.setParam(":VBUYING_ID", paramString);
    this.tradeQuery.executeBy(localStockorderExt.insBy("UNLOAD_BY_ID"));
    return 0;
  }

  public void setNow(Buffers paramBuffers)
  {
    this.log.LOG_INFO("进入delStockorder方法...");
    this.outBuffer = paramBuffers;
    String str1 = "";
    String str2 = paramBuffers.getString("buying_id");
    String[] arrayOfString = str2.split(",");
    for (int i = 0; i < arrayOfString.length; i++)
    {
      str1 = arrayOfString[i];
      if ((str1 == null) || (str1.equals("")))
        continue;
      int j = -1;
      try
      {
        j = setNow(str1);
      }
      catch (SaasApplicationException localSaasApplicationException)
      {
        this.log.LOG_INFO(localSaasApplicationException.getMessage());
      }
      if (j != 0)
      {
        this.outBuffer.setInt("RESULT_CODE", -1);
        this.outBuffer.setString("RESULT_INFO", "业务处理失败！");
      }
      else
      {
        this.outBuffer.setInt("RESULT_CODE", 0);
        this.outBuffer.setString("RESULT_INFO", "业务处理成功！");
      }
      this.log.LOG_INFO("退出delStockorder方法...");
    }
  }

  public int setNow(String paramString)
    throws SaasApplicationException
  {
    StockorderExt localStockorderExt = new StockorderExt();
    localStockorderExt.setParam(":VBUYING_ID", paramString);
    this.tradeQuery.executeBy(localStockorderExt.insBy("INS_BY_BUYING_ID"));
    return 0;
  }

  public void setTop(Buffers paramBuffers)
  {
    this.log.LOG_INFO("进入setTop方法...");
    this.outBuffer = paramBuffers;
    String str1 = "";
    String str2 = paramBuffers.getString("buying_id");
    String[] arrayOfString = str2.split(",");
    for (int i = 0; i < arrayOfString.length; i++)
    {
      str1 = arrayOfString[i];
      if ((str1 == null) || (str1.equals("")))
        continue;
      int j = -1;
      try
      {
        j = setTop(str1);
      }
      catch (SaasApplicationException localSaasApplicationException)
      {
        this.log.LOG_INFO(localSaasApplicationException.getMessage());
      }
      if (j != 0)
      {
        this.outBuffer.setInt("RESULT_CODE", -1);
        this.outBuffer.setString("RESULT_INFO", "业务处理失败！");
      }
      else
      {
        this.outBuffer.setInt("RESULT_CODE", 0);
        this.outBuffer.setString("RESULT_INFO", "业务处理成功！");
      }
      this.log.LOG_INFO("退出delStockorder方法...");
    }
  }

  public int setTop(String paramString)
    throws SaasApplicationException
  {
    StockorderExt localStockorderExt = new StockorderExt();
    ArrayList localArrayList = genOneStockorder(paramString);
    String str = "";
    if ((localArrayList != null) && (localArrayList.size() > 0))
      for (int i = 0; i < localArrayList.size(); i++)
      {
        HashMap localHashMap = (HashMap)localArrayList.get(i);
        if (localHashMap.get("list_top") == null)
          continue;
        str = localHashMap.get("list_top").toString();
        localStockorderExt.setParam(":VBUYING_ID", paramString);
        if (!str.equals("0"))
          localStockorderExt.setParam(":VLIST_TOP", Integer.valueOf(0));
        if (str.equals("0"))
          localStockorderExt.setParam(":VLIST_TOP", Integer.valueOf(1));
        this.tradeQuery.executeBy(localStockorderExt.insBy("UP_TIME_BY_BUYING_ID"));
      }
    return 0;
  }

  public ArrayList genOneStockorder(String paramString)
    throws SaasApplicationException
  {
    ArrayList localArrayList = new ArrayList();
    StockorderExt localStockorderExt = new StockorderExt();
    localStockorderExt.setParam(":VBUYING_ID", paramString);
    localArrayList = localStockorderExt.selByList("SEL_BY_PK");
    return localArrayList;
  }

  public void delStock(Buffers paramBuffers)
  {
    this.log.LOG_INFO("进入delStockorder方法...");
    this.outBuffer = paramBuffers;
    String str1 = "";
    String str2 = "";
    String str3 = paramBuffers.getString("buying_id");
    String[] arrayOfString = str3.split(",");
    for (int i = 0; i < arrayOfString.length; i++)
    {
      str1 = arrayOfString[i];
      if ((str1 == null) || (str1.equals("")))
        continue;
      Stockorderinfo localStockorderinfo = new Stockorderinfo();
      ArrayList localArrayList = localStockorderinfo.genCustStockorder(str1);
      if ((localArrayList != null) && (localArrayList.size() > 0))
      {
        HashMap localHashMap = (HashMap)localArrayList.get(0);
        if (localHashMap.get("validity") != null)
          str2 = localHashMap.get("validity").toString();
      }
      int j = -1;
      try
      {
        j = delStock(str1, str2);
      }
      catch (SaasApplicationException localSaasApplicationException)
      {
        this.log.LOG_INFO(localSaasApplicationException.getMessage());
      }
      if (j != 0)
      {
        this.outBuffer.setInt("RESULT_CODE", -1);
        this.outBuffer.setString("RESULT_INFO", "业务处理失败！");
      }
      else
      {
        this.outBuffer.setInt("RESULT_CODE", 0);
        this.outBuffer.setString("RESULT_INFO", "业务处理成功！");
      }
      this.log.LOG_INFO("退出delStockorder方法...");
    }
  }

  public int delStock(String paramString1, String paramString2)
    throws SaasApplicationException
  {
    String str = "select n.class_id,c.store_path,c.article_rule from buying n,buying_class c where c.class_id = n.class_id and buying_id = '" + paramString1 + "'";
    CommMethodMgr.deleteContentPage(paramString1, str);
    StockorderExt localStockorderExt = new StockorderExt();
    localStockorderExt.setParam(":VBUYING_ID", paramString1);
    if (paramString2.equals("1"))
      this.tradeQuery.executeBy(localStockorderExt.insBy("DEL_BY_ID_huiyuan"));
    else
      this.tradeQuery.executeBy(localStockorderExt.insBy("DEL_BY_BUYINGID"));
    return 0;
  }

  public void delStockorder(Buffers paramBuffers)
  {
    this.log.LOG_INFO("进入delStockorder方法...");
    this.outBuffer = paramBuffers;
    String str1 = "";
    String str2 = paramBuffers.getString("buying_id");
    String[] arrayOfString = str2.split(",");
    for (int i = 0; i < arrayOfString.length; i++)
    {
      str1 = arrayOfString[i];
      if ((str1 == null) || (str1.equals("")))
        continue;
      int j = -1;
      try
      {
        j = delStockorder(str1);
      }
      catch (SaasApplicationException localSaasApplicationException)
      {
        this.log.LOG_INFO(localSaasApplicationException.getMessage());
      }
      if (j != 0)
      {
        this.outBuffer.setInt("RESULT_CODE", -1);
        this.outBuffer.setString("RESULT_INFO", "业务处理失败！");
      }
      else
      {
        this.outBuffer.setInt("RESULT_CODE", 0);
        this.outBuffer.setString("RESULT_INFO", "业务处理成功！");
      }
      this.log.LOG_INFO("退出delStockorder方法...");
    }
  }

  public int delStockorder(String paramString)
    throws SaasApplicationException
  {
    String str = "select n.class_id,c.store_path,c.article_rule from buying n,buying_class c where c.class_id = n.class_id and buying_id = '" + paramString + "'";
    CommMethodMgr.deleteContentPage(paramString, str);
    StockorderExt localStockorderExt = new StockorderExt();
    localStockorderExt.setParam(":VVALIDITY", Integer.valueOf(9));
    localStockorderExt.setParam(":VBUYING_ID", paramString);
    this.tradeQuery.executeBy(localStockorderExt.insBy("DEL_BY_ID"));
    return 0;
  }

  public void reStockorder(Buffers paramBuffers)
  {
    this.log.LOG_INFO("进入delStockorder方法...");
    this.outBuffer = paramBuffers;
    String str1 = "";
    String str2 = paramBuffers.getString("buying_id");
    String[] arrayOfString = str2.split(",");
    for (int i = 0; i < arrayOfString.length; i++)
    {
      str1 = arrayOfString[i];
      if ((str1 == null) || (str1.equals("")))
        continue;
      int j = -1;
      try
      {
        j = reStockorder(str1);
      }
      catch (SaasApplicationException localSaasApplicationException)
      {
        this.log.LOG_INFO(localSaasApplicationException.getMessage());
      }
      if (j != 0)
      {
        this.outBuffer.setInt("RESULT_CODE", -1);
        this.outBuffer.setString("RESULT_INFO", "业务处理失败！");
      }
      else
      {
        this.outBuffer.setInt("RESULT_CODE", 0);
        this.outBuffer.setString("RESULT_INFO", "业务处理成功！");
      }
      this.log.LOG_INFO("退出delStockorder方法...");
    }
  }

  public int reStockorder(String paramString)
    throws SaasApplicationException
  {
    StockorderExt localStockorderExt = new StockorderExt();
    localStockorderExt.setParam(":VBUYING_ID", paramString);
    this.tradeQuery.executeBy(localStockorderExt.insBy("RETURN_BY_ID"));
    return 0;
  }

  public void setDis(Buffers paramBuffers)
  {
    this.log.LOG_INFO("进入delStockorder方法...");
    this.outBuffer = paramBuffers;
    String str1 = "";
    String str2 = paramBuffers.getString("buying_id");
    String[] arrayOfString = str2.split(",");
    for (int i = 0; i < arrayOfString.length; i++)
    {
      str1 = arrayOfString[i];
      if ((str1 == null) || (str1.equals("")))
        continue;
      int j = -1;
      try
      {
        j = setDis(str1);
      }
      catch (SaasApplicationException localSaasApplicationException)
      {
        this.log.LOG_INFO(localSaasApplicationException.getMessage());
      }
      if (j != 0)
      {
        this.outBuffer.setInt("RESULT_CODE", -1);
        this.outBuffer.setString("RESULT_INFO", "业务处理失败！");
      }
      else
      {
        this.outBuffer.setInt("RESULT_CODE", 0);
        this.outBuffer.setString("RESULT_INFO", "业务处理成功！");
      }
      this.log.LOG_INFO("退出delStockorder方法...");
    }
  }

  public int setDis(String paramString)
    throws SaasApplicationException
  {
    StockorderExt localStockorderExt = new StockorderExt();
    ArrayList localArrayList = genOneStockorder(paramString);
    String str = "";
    if ((localArrayList != null) && (localArrayList.size() > 0))
      for (int i = 0; i < localArrayList.size(); i++)
      {
        HashMap localHashMap = (HashMap)localArrayList.get(i);
        if (localHashMap.get("display") == null)
          continue;
        str = localHashMap.get("display").toString();
        localStockorderExt.setParam(":VBUYING_ID", paramString);
        if (str.equals("1"))
          localStockorderExt.setParam(":VDISPLAY", Integer.valueOf(0));
        if (str.equals("0"))
          localStockorderExt.setParam(":VDISPLAY", Integer.valueOf(1));
        this.tradeQuery.executeBy(localStockorderExt.insBy("VDISPLAY_BY_BUYING_ID"));
      }
    return 0;
  }

  public void setCheck(Buffers paramBuffers)
  {
    this.log.LOG_INFO("进入delStockorder方法...");
    this.outBuffer = paramBuffers;
    StockorderDAO localStockorderDAO = new StockorderDAO();
    localStockorderDAO.setCheck_user(paramBuffers.getString("oper_user"));
    localStockorderDAO.setBack_reason(paramBuffers.getString("back_reason"));
    localStockorderDAO.setValidity(paramBuffers.getString("VALIDITY"));
    localStockorderDAO.setBuying_id(paramBuffers.getString("buying_id"));
    int i = -1;
    try
    {
      i = setCheck(localStockorderDAO);
    }
    catch (SaasApplicationException localSaasApplicationException)
    {
      this.log.LOG_INFO(localSaasApplicationException.getMessage());
    }
    if (i != 0)
    {
      this.outBuffer.setInt("RESULT_CODE", -1);
      this.outBuffer.setString("RESULT_INFO", "业务处理失败！");
    }
    else
    {
      this.outBuffer.setInt("RESULT_CODE", 0);
      this.outBuffer.setString("RESULT_INFO", "业务处理成功！");
    }
    String str1 = paramBuffers.getString("TRADE_TYPE_CODE");
    String str2 = new ScoreListInfo().getOperName(str1);
    if (paramBuffers.getString("VALIDITY").equals("1"))
    {
      this.outBuffer.setString("BUILD", "1");
      this.outBuffer.setString("TABLENAME", "buying");
      this.outBuffer.setString("ID", paramBuffers.getString("buying_id"));
      this.outBuffer.setString("OPER_NAME", str2);
    }
    this.log.LOG_INFO("退出delStockorder方法...");
  }

  public int setCheck(StockorderDAO paramStockorderDAO)
    throws SaasApplicationException
  {
    StockorderExt localStockorderExt = new StockorderExt();
    localStockorderExt.setParam(":VBUYING_ID", paramStockorderDAO.getBuying_id());
    localStockorderExt.setParam(":VCHECK_USER", paramStockorderDAO.getCheck_user());
    localStockorderExt.setParam(":VVALIDITY", paramStockorderDAO.getValidity());
    localStockorderExt.setParam(":VBACK_REASON", paramStockorderDAO.getBack_reason());
    this.tradeQuery.executeBy(localStockorderExt.insBy("CHECK_BY_BUYING_ID"));
    return 0;
  }

  public void setChecks(Buffers paramBuffers)
  {
    this.outBuffer = paramBuffers;
    this.inBuffer = paramBuffers;
    int i = -1;
    String str1 = paramBuffers.getString("BUYING_ID");
    String str2 = paramBuffers.getString("VALIDITY");
    String str3 = paramBuffers.getString("BACK_REASON");
    String str4 = paramBuffers.getString("CHECK_USER");
    String str5 = paramBuffers.getString("CUST_ID");
    try
    {
      StringTokenizer localStringTokenizer = new StringTokenizer(str1, "|");
      StringTokenizer localObject = new StringTokenizer(str5, "|");
      String str7 = "";
      String str8 = "";
      while (localStringTokenizer.hasMoreTokens())
      {
        str8 = localStringTokenizer.nextToken();
        str7 = ((StringTokenizer)localObject).nextToken();
        i = setChecks(str8, str2, str3, str4);
      }
    }
    catch (SaasApplicationException localSaasApplicationException)
    {
      this.log.LOG_INFO(localSaasApplicationException.getMessage());
    }
    if (i != 0)
    {
      this.outBuffer.setInt("RESULT_CODE", -1);
      this.outBuffer.setString("RESULT_INFO", "业务处理失败！");
    }
    else
    {
      this.outBuffer.setInt("RESULT_CODE", 0);
      this.outBuffer.setString("RESULT_INFO", "业务处理成功！");
    }
    String str6 = paramBuffers.getString("TRADE_TYPE_CODE");
    Object localObject = new ScoreListInfo().getOperName(str6);
    if (str2.equals("1"))
    {
      this.outBuffer.setString("BUILD", "2");
      this.outBuffer.setString("TABLENAME", "buying");
      this.outBuffer.setString("ID", str1);
      this.outBuffer.setString("OPER_NAME", (String)localObject);
    }
    this.log.LOG_INFO("退出delByClassId方法...");
  }

  public int setChecks(String paramString1, String paramString2, String paramString3, String paramString4)
    throws SaasApplicationException
  {
    StockorderExt localStockorderExt = new StockorderExt();
    localStockorderExt.setParam(":VBUYING_ID", paramString1);
    localStockorderExt.setParam(":VVALIDITY", paramString2);
    localStockorderExt.setParam(":VBACK_REASON", paramString3);
    localStockorderExt.setParam(":VCHECK_USER", paramString4);
    this.tradeQuery.executeBy(localStockorderExt.insBy("CHECK_BY_BUYING_ID"));
    return 0;
  }

  public void setGood(Buffers paramBuffers)
  {
    this.log.LOG_INFO("进入delStockorder方法...");
    this.outBuffer = paramBuffers;
    String str1 = "";
    String str2 = paramBuffers.getString("buying_id");
    String[] arrayOfString = str2.split(",");
    for (int i = 0; i < arrayOfString.length; i++)
    {
      str1 = arrayOfString[i];
      if ((str1 == null) || (str1.equals("")))
        continue;
      int j = -1;
      try
      {
        j = setGood(str1);
      }
      catch (SaasApplicationException localSaasApplicationException)
      {
        this.log.LOG_INFO(localSaasApplicationException.getMessage());
      }
      if (j != 0)
      {
        this.outBuffer.setInt("RESULT_CODE", -1);
        this.outBuffer.setString("RESULT_INFO", "业务处理失败！");
      }
      else
      {
        this.outBuffer.setInt("RESULT_CODE", 0);
        this.outBuffer.setString("RESULT_INFO", "业务处理成功！");
      }
      this.log.LOG_INFO("退出delStockorder方法...");
    }
  }

  public int setGood(String paramString)
    throws SaasApplicationException
  {
    StockorderExt localStockorderExt = new StockorderExt();
    ArrayList localArrayList = genOneStockorder(paramString);
    String str = "";
    if ((localArrayList != null) && (localArrayList.size() > 0))
      for (int i = 0; i < localArrayList.size(); i++)
      {
        HashMap localHashMap = (HashMap)localArrayList.get(i);
        if (localHashMap.get("good_buying") == null)
          continue;
        str = localHashMap.get("good_buying").toString();
        localStockorderExt.setParam(":VBUYING_ID", paramString);
        if (str.equals("1"))
          localStockorderExt.setParam(":VGOOD_BUYING", Integer.valueOf(0));
        if (str.equals("0"))
          localStockorderExt.setParam(":VGOOD_BUYING", Integer.valueOf(1));
        this.tradeQuery.executeBy(localStockorderExt.insBy("GOOD_BY_BUYING_ID"));
      }
    return 0;
  }

  public void setCommend(Buffers paramBuffers)
  {
    this.log.LOG_INFO("进入delStockorder方法...");
    this.outBuffer = paramBuffers;
    String str1 = "";
    String str2 = paramBuffers.getString("buying_id");
    String[] arrayOfString = str2.split(",");
    for (int i = 0; i < arrayOfString.length; i++)
    {
      str1 = arrayOfString[i];
      if ((str1 == null) || (str1.equals("")))
        continue;
      int j = -1;
      try
      {
        j = setCommend(str1);
      }
      catch (SaasApplicationException localSaasApplicationException)
      {
        this.log.LOG_INFO(localSaasApplicationException.getMessage());
      }
      if (j != 0)
      {
        this.outBuffer.setInt("RESULT_CODE", -1);
        this.outBuffer.setString("RESULT_INFO", "业务处理失败！");
      }
      else
      {
        this.outBuffer.setInt("RESULT_CODE", 0);
        this.outBuffer.setString("RESULT_INFO", "业务处理成功！");
      }
      this.log.LOG_INFO("退出delStockorder方法...");
    }
  }

  public int setCommend(String paramString)
    throws SaasApplicationException
  {
    StockorderExt localStockorderExt = new StockorderExt();
    ArrayList localArrayList = genOneStockorder(paramString);
    String str = "";
    if ((localArrayList != null) && (localArrayList.size() > 0))
      for (int i = 0; i < localArrayList.size(); i++)
      {
        HashMap localHashMap = (HashMap)localArrayList.get(i);
        if (localHashMap.get("commend") == null)
          continue;
        str = localHashMap.get("commend").toString();
        localStockorderExt.setParam(":VBUYING_ID", paramString);
        if (str.equals("1"))
          localStockorderExt.setParam(":VCOMMEND", Integer.valueOf(0));
        if (str.equals("0"))
          localStockorderExt.setParam(":VCOMMEND", Integer.valueOf(1));
        this.tradeQuery.executeBy(localStockorderExt.insBy("COMMEND_BY_BUYING_ID"));
      }
    return 0;
  }

  public void setDown(Buffers paramBuffers)
  {
    this.log.LOG_INFO("进入setDown(Buffers inbuffer)方法...");
    this.outBuffer = paramBuffers;
    String str1 = "";
    String str2 = paramBuffers.getString("buying_id");
    String[] arrayOfString = str2.split(",");
    for (int i = 0; i < arrayOfString.length; i++)
    {
      str1 = arrayOfString[i];
      if ((str1 == null) || (str1.equals("")))
        continue;
      int j = -1;
      try
      {
        j = setDown(str1);
      }
      catch (SaasApplicationException localSaasApplicationException)
      {
        this.log.LOG_INFO(localSaasApplicationException.getMessage());
      }
      if (j != 0)
      {
        this.outBuffer.setInt("RESULT_CODE", -1);
        this.outBuffer.setString("RESULT_INFO", "业务处理失败！");
      }
      else
      {
        this.outBuffer.setInt("RESULT_CODE", 0);
        this.outBuffer.setString("RESULT_INFO", "业务处理成功！");
      }
      this.log.LOG_INFO("setDown(Buffers inbuffer)");
    }
  }

  public int setDown(String paramString)
    throws SaasApplicationException
  {
    StockorderExt localStockorderExt = new StockorderExt();
    ArrayList localArrayList = genOneStockorder(paramString);
    String str = "";
    if ((localArrayList != null) && (localArrayList.size() > 0))
      for (int i = 0; i < localArrayList.size(); i++)
      {
        HashMap localHashMap = (HashMap)localArrayList.get(i);
        if (localHashMap.get("list_top") == null)
          continue;
        str = localHashMap.get("list_top").toString();
        localStockorderExt.setParam(":VBUYING_ID", paramString);
        if (!str.equals("2"))
          localStockorderExt.setParam(":VLIST_TOP", Integer.valueOf(2));
        if ("2".equals(str))
          localStockorderExt.setParam(":VLIST_TOP", Integer.valueOf(1));
        this.tradeQuery.executeBy(localStockorderExt.insBy("LIST_TOP_BY_BUYING_ID"));
      }
    return 0;
  }

  public void DeleteStockInfo(Buffers paramBuffers)
  {
    this.log.LOG_INFO("进入DeleteStockInfo方法...");
    this.outBuffer = paramBuffers;
    this.inBuffer = paramBuffers;
    int i = -1;
    String str1 = paramBuffers.getString("STOCK_ID");
    try
    {
      StringTokenizer localStringTokenizer = new StringTokenizer(str1, "|");
      String str2 = "";
      while (localStringTokenizer.hasMoreTokens())
      {
        str2 = localStringTokenizer.nextToken();
        i = delStockorder(str2);
      }
    }
    catch (SaasApplicationException localSaasApplicationException)
    {
      this.log.LOG_INFO(localSaasApplicationException.getMessage());
    }
    if (i != 0)
    {
      this.outBuffer.setInt("RESULT_CODE", -1);
      this.outBuffer.setString("RESULT_INFO", "业务处理失败！");
    }
    else
    {
      this.outBuffer.setInt("RESULT_CODE", 0);
      this.outBuffer.setString("RESULT_INFO", "业务处理成功！");
    }
    this.log.LOG_INFO("退出DeleteStockInfo方法...");
  }

  public ArrayList getStockListByAll(int paramInt, String paramString)
    throws SaasApplicationException
  {
    ArrayList localArrayList = new ArrayList();
    StockorderExt localStockorderExt = new StockorderExt();
    localStockorderExt.setParam(":VCUST_ID", paramString);
    if (paramInt == 0)
      paramInt = 0;
    else
      paramInt = (paramInt - 1) * 30;
    localStockorderExt.setParam(":VVALIDITY", "0");
    localArrayList = localStockorderExt.selByList("SEL_CUST_STOCKORDER", paramInt, 30);
    return localArrayList;
  }

  public ArrayList getALLStockListByAll(int paramInt, String paramString)
    throws SaasApplicationException
  {
    ArrayList localArrayList = new ArrayList();
    StockorderExt localStockorderExt = new StockorderExt();
    localStockorderExt.setParam(":VCUST_ID", paramString);
    if (paramInt == 0)
      paramInt = 0;
    else
      paramInt = (paramInt - 1) * 30;
    localStockorderExt.setParam(":VVALIDITY", "0");
    localArrayList = localStockorderExt.selByList("SEL_ALL_CUST_STOCKORDER", paramInt, 30);
    return localArrayList;
  }

  public ArrayList getStockListMemberByAll(int paramInt, String paramString)
    throws SaasApplicationException
  {
    ArrayList localArrayList = new ArrayList();
    StockorderExt localStockorderExt = new StockorderExt();
    localStockorderExt.setParam(":VCUST_ID", paramString);
    if (paramInt == 0)
      paramInt = 0;
    else
      paramInt = (paramInt - 1) * 30;
    localArrayList = localStockorderExt.selByList("SEL_ALL_MEMBER_CUST_STOCKORDER", paramInt, 30);
    return localArrayList;
  }

  public int getStockListMemberByAll(String paramString)
    throws SaasApplicationException
  {
    ArrayList localArrayList = new ArrayList();
    StockorderExt localStockorderExt = new StockorderExt();
    localStockorderExt.setParam(":VCUST_ID", paramString);
    localArrayList = localStockorderExt.selByList("SEL_ALL_MEMBER_CUST_STOCKORDER");
    if (localArrayList != null)
      return localArrayList.size();
    return 0;
  }

  public ArrayList getStockListByKey(int paramInt, String paramString1, String paramString2)
    throws SaasApplicationException
  {
    ArrayList localArrayList = new ArrayList();
    StockorderExt localStockorderExt = new StockorderExt();
    localStockorderExt.setParam(":VCUST_ID", paramString1);
    localStockorderExt.setParam(":VKEY_WORD", "%" + paramString2 + "%");
    if (paramInt == 0)
      paramInt = 0;
    else
      paramInt = (paramInt - 1) * 30;
    localArrayList = localStockorderExt.selByList("SEARCH_KEY_CUST_STOCKORDER", paramInt, 30);
    return localArrayList;
  }

  public ArrayList getStockMemberListByKey(int paramInt, String paramString1, String paramString2)
    throws SaasApplicationException
  {
    ArrayList localArrayList = new ArrayList();
    StockorderExt localStockorderExt = new StockorderExt();
    localStockorderExt.setParam(":VCUST_ID", paramString1);
    localStockorderExt.setParam(":VKEY_WORD", "%" + paramString2 + "%");
    if (paramInt == 0)
      paramInt = 0;
    else
      paramInt = (paramInt - 1) * 30;
    localArrayList = localStockorderExt.selByList("SEARCH_KEY_CUST_STOCKORDER_BY_CUSTID", paramInt, 30);
    return localArrayList;
  }

  public ArrayList getStockListByDate(int paramInt, String paramString1, String paramString2, String paramString3)
    throws SaasApplicationException
  {
    this.log.LOG_INFO("--------------------------startTime==============" + paramString2);
    this.log.LOG_INFO("--------------------------endTime==============" + paramString3);
    ArrayList localArrayList = new ArrayList();
    StockorderExt localStockorderExt = new StockorderExt();
    localStockorderExt.setParam(":VCUST_ID", paramString1);
    localStockorderExt.setParam(":VSTART_TIME", paramString2);
    localStockorderExt.setParam(":VEND_TIME", paramString3);
    if (paramInt == 0)
      paramInt = 0;
    else
      paramInt = (paramInt - 1) * 30;
    localStockorderExt.setParam(":VVALIDITY", "0");
    localArrayList = localStockorderExt.selByList("SEARCH_DATE_CUST_STOCKORDER", paramInt, 30);
    return localArrayList;
  }

  public int getStockListNumberByTime(String paramString1, String paramString2, String paramString3)
    throws SaasApplicationException
  {
    ArrayList localArrayList = new ArrayList();
    StockorderExt localStockorderExt = new StockorderExt();
    localStockorderExt.setParam(":VVALIDITY", "0");
    localStockorderExt.setParam(":VCUST_ID", paramString1);
    localStockorderExt.setParam(":VSTART_TIME", paramString2);
    localStockorderExt.setParam(":VEND_TIME", paramString3);
    localArrayList = localStockorderExt.selByList("SEARCH_DATE_CUST_STOCKORDER");
    if (localArrayList != null)
      return localArrayList.size();
    return 0;
  }

  public int getStockListNumberByKey(String paramString1, String paramString2)
    throws SaasApplicationException
  {
    ArrayList localArrayList = new ArrayList();
    StockorderExt localStockorderExt = new StockorderExt();
    localStockorderExt.setParam(":VVALIDITY", "0");
    localStockorderExt.setParam(":VCUST_ID", paramString1);
    localStockorderExt.setParam(":VKEY_WORD", "%" + paramString2 + "%");
    localArrayList = localStockorderExt.selByList("SEARCH_KEY_CUST_STOCKORDER_BY_CUSTID");
    if (localArrayList != null)
      return localArrayList.size();
    return 0;
  }

  public int getStockListMemberByKey(String paramString1, String paramString2)
    throws SaasApplicationException
  {
    ArrayList localArrayList = new ArrayList();
    StockorderExt localStockorderExt = new StockorderExt();
    localStockorderExt.setParam(":VVALIDITY", "0");
    localStockorderExt.setParam(":VCUST_ID", paramString1);
    localStockorderExt.setParam(":VKEY_WORD", "%" + paramString2 + "%");
    localArrayList = localStockorderExt.selByList("SEARCH_KEY_CUST_STOCKORDER");
    if (localArrayList != null)
      return localArrayList.size();
    return 0;
  }

  public int getStockListNumber(String paramString)
    throws SaasApplicationException
  {
    int i = 0;
    ArrayList localArrayList = new ArrayList();
    StockorderExt localStockorderExt = new StockorderExt();
    localStockorderExt.setParam(":VCUST_ID", paramString);
    localArrayList = localStockorderExt.selByList("SEL_STOCK_CT");
    if ((localArrayList != null) && (localArrayList.size() > 0))
    {
      HashMap localHashMap = (HashMap)localArrayList.get(0);
      i = Integer.parseInt(localHashMap.get("ct").toString());
    }
    return i;
  }

  public int getOffStockListNumber(String paramString)
    throws SaasApplicationException
  {
    int i = 0;
    ArrayList localArrayList = new ArrayList();
    StockorderExt localStockorderExt = new StockorderExt();
    localStockorderExt.setParam(":VVALIDITY", "0");
    localStockorderExt.setParam(":VCUST_ID", paramString);
    localArrayList = localStockorderExt.selByList("SEL_CUST_OFF_STOCK");
    if ((localArrayList != null) && (localArrayList.size() > 0))
    {
      HashMap localHashMap = (HashMap)localArrayList.get(0);
      i = Integer.parseInt(localHashMap.get("ct").toString());
    }
    return i;
  }

  public ArrayList getStockListBySearch(int paramInt, String paramString)
    throws SaasApplicationException
  {
    if (paramInt == 0)
      paramInt = 0;
    else
      paramInt = (paramInt - 1) * 30;
    ArrayList localArrayList = new ArrayList();
    StockorderExt localStockorderExt = new StockorderExt();
    localStockorderExt.setParam(":VCONTENT", "%" + paramString.trim() + "%");
    localArrayList = localStockorderExt.selByList("SEL_BY_KEYS", paramInt, 30);
    return localArrayList;
  }

  public int getStockSearch(String paramString)
    throws SaasApplicationException
  {
    ArrayList localArrayList = new ArrayList();
    StockorderExt localStockorderExt = new StockorderExt();
    localStockorderExt.setParam(":VCONTENT", "%" + paramString.trim() + "%");
    localArrayList = localStockorderExt.selByList("SEL_BY_KEYS");
    if (localArrayList != null)
      return localArrayList.size();
    return 0;
  }

  public int getStockToday()
    throws SaasApplicationException
  {
    ArrayList localArrayList = new ArrayList();
    StockorderExt localStockorderExt = new StockorderExt();
    localArrayList = localStockorderExt.selByList("SEL_BY_TODAY_COUNT");
    if (localArrayList != null)
      return localArrayList.size();
    return 0;
  }

  public ArrayList getStockListBy()
    throws SaasApplicationException
  {
    ArrayList localArrayList = new ArrayList();
    StockorderExt localStockorderExt = new StockorderExt();
    localStockorderExt.setParam(":VVALIDITY", "0");
    localArrayList = localStockorderExt.selByList("SEL_CUST_NEW_STOCK");
    return localArrayList;
  }

  public void reloadStockInfo(Buffers paramBuffers)
  {
    this.log.LOG_INFO("进入reloadStockInfo方法...");
    this.outBuffer = paramBuffers;
    this.inBuffer = paramBuffers;
    int i = -1;
    String str1 = paramBuffers.getString("STOCK_ID");
    try
    {
      StringTokenizer localStringTokenizer = new StringTokenizer(str1, "|");
      String str2 = "";
      while (localStringTokenizer.hasMoreTokens())
      {
        str2 = localStringTokenizer.nextToken();
        i = reloadStockInfo(str2);
      }
    }
    catch (SaasApplicationException localSaasApplicationException)
    {
      this.log.LOG_INFO(localSaasApplicationException.getMessage());
    }
    if (i != 0)
    {
      this.outBuffer.setInt("RESULT_CODE", -1);
      this.outBuffer.setString("RESULT_INFO", "业务处理失败！");
    }
    else
    {
      this.outBuffer.setInt("RESULT_CODE", 0);
      this.outBuffer.setString("RESULT_INFO", "业务处理成功！");
    }
    this.log.LOG_INFO("退出reloadNewsInfo方法...");
  }

  public int reloadStockInfo(String paramString)
    throws SaasApplicationException
  {
    StockorderExt localStockorderExt = new StockorderExt();
    localStockorderExt.setParam(":VSTOCK_ID", paramString);
    this.tradeQuery.executeBy(localStockorderExt.insBy("RELOAD_STOCK_BY_STOCK_ID"));
    return 0;
  }

  public ArrayList getSearchStockInfo(int paramInt1, int paramInt2, String paramString1, String paramString2, String paramString3, int paramInt3)
    throws SaasApplicationException
  {
    this.log.LOG_INFO("进入getSearchStockInfo方法");
    if (paramInt1 > 1)
      paramInt1 = (paramInt1 - 1) * paramInt2;
    else
      paramInt1 = 0;
    Calendar localCalendar = Calendar.getInstance();
    localCalendar.add(5, -paramInt3);
    String str = new SimpleDateFormat("yyyy-MM-dd").format(localCalendar.getTime());
    ArrayList localArrayList = new ArrayList();
    StockorderExt localStockorderExt = new StockorderExt();
    localStockorderExt.setParam(":VKEY", "%" + paramString1 + "%");
    localStockorderExt.setParam(":VPRO", "%" + paramString2 + "%");
    localStockorderExt.setParam(":VCITY", "%" + paramString3 + "%");
    localStockorderExt.setParam(":VDATE", str);
    if ((paramString2.equals("")) && (paramInt3 != 365))
      localArrayList = localStockorderExt.selByList("SEL_NO_PRO_CITY", paramInt1, paramInt2);
    else if ((paramString3.equals("")) && (!paramString2.equals("")) && (paramInt3 != 365))
      localArrayList = localStockorderExt.selByList("SEL_NO_CITY", paramInt1, paramInt2);
    else if ((paramInt3 == 365) && (!paramString2.equals("")) && (!paramString3.equals("")))
      localArrayList = localStockorderExt.selByList("SEL_NO_DATE", paramInt1, paramInt2);
    else
      localArrayList = localStockorderExt.selByList("SEL_BY_KEY", paramInt1, paramInt2);
    this.log.LOG_INFO("退出getSearchStockInfo方法");
    return localArrayList;
  }

  public int getSearchStockInfo(String paramString1, String paramString2, String paramString3, int paramInt)
    throws SaasApplicationException
  {
    int i = 0;
    Calendar localCalendar = Calendar.getInstance();
    localCalendar.add(5, -paramInt);
    String str = new SimpleDateFormat("yyyy-MM-dd").format(localCalendar.getTime());
    ArrayList localArrayList = new ArrayList();
    StockorderExt localStockorderExt = new StockorderExt();
    localStockorderExt.setParam(":VKEY", "%" + paramString1 + "%");
    localStockorderExt.setParam(":VPRO", "%" + paramString2 + "%");
    localStockorderExt.setParam(":VCITY", "%" + paramString3 + "%");
    localStockorderExt.setParam(":VDATE", str);
    if ((paramString2.equals("")) && (paramInt != 365))
      localArrayList = localStockorderExt.selByList("SEL_NO_PRO_CITY");
    else if ((paramString3.equals("")) && (!paramString2.equals("")) && (paramInt != 365))
      localArrayList = localStockorderExt.selByList("SEL_NO_CITY");
    else if ((paramInt == 365) && (!paramString2.equals("")) && (!paramString3.equals("")))
      localArrayList = localStockorderExt.selByList("SEL_NO_DATE");
    else
      localArrayList = localStockorderExt.selByList("SEL_BY_KEY");
    if ((localArrayList != null) && (localArrayList.size() > 0))
      i = localArrayList.size();
    return i;
  }

  public ArrayList getSearchStockList(int paramInt1, int paramInt2, String paramString1, String paramString2, String paramString3, int paramInt3)
    throws SaasApplicationException
  {
    this.log.LOG_INFO("进入getSearchStockList方法");
    if (paramInt1 > 1)
      paramInt1 = (paramInt1 - 1) * paramInt2;
    else
      paramInt1 = 0;
    Calendar localCalendar = Calendar.getInstance();
    localCalendar.add(5, -paramInt3);
    String str = new SimpleDateFormat("yyyy-MM-dd").format(localCalendar.getTime());
    ArrayList localArrayList = new ArrayList();
    StockorderExt localStockorderExt = new StockorderExt();
    localStockorderExt.setParam(":VKEY", paramString1);
    localStockorderExt.setParam(":VPRO", paramString2);
    localStockorderExt.setParam(":VCITY", paramString3);
    localStockorderExt.setParam(":VDATE", str);
    if ((paramString2.equals("")) && (paramInt3 != 365))
      localArrayList = localStockorderExt.selByList("SEL_NO_PRO_CITYSS", paramInt1, paramInt2);
    else if ((paramString3.equals("")) && (!paramString2.equals("")) && (paramInt3 != 365))
      localArrayList = localStockorderExt.selByList("SEL_NO_CITYSS", paramInt1, paramInt2);
    else if ((paramInt3 == 365) && (!paramString2.equals("")) && (!paramString3.equals("")))
      localArrayList = localStockorderExt.selByList("SEL_NO_DATESS", paramInt1, paramInt2);
    else
      localArrayList = localStockorderExt.selByList("SEL_BY_KEYSS", paramInt1, paramInt2);
    this.log.LOG_INFO("退出getSearchStockList方法");
    return localArrayList;
  }

  public int getSearchStockList(String paramString1, String paramString2, String paramString3, int paramInt)
    throws SaasApplicationException
  {
    int i = 0;
    Calendar localCalendar = Calendar.getInstance();
    localCalendar.add(5, -paramInt);
    String str = new SimpleDateFormat("yyyy-MM-dd").format(localCalendar.getTime());
    ArrayList localArrayList = new ArrayList();
    StockorderExt localStockorderExt = new StockorderExt();
    localStockorderExt.setParam(":VKEY", paramString1);
    localStockorderExt.setParam(":VPRO", paramString2);
    localStockorderExt.setParam(":VCITY", paramString3);
    localStockorderExt.setParam(":VDATE", str);
    if ((paramString2.equals("")) && (paramInt != 365))
      localArrayList = localStockorderExt.selByList("SEL_NO_PRO_CITYSS");
    else if ((paramString3.equals("")) && (!paramString2.equals("")) && (paramInt != 365))
      localArrayList = localStockorderExt.selByList("SEL_NO_CITYSS");
    else if ((paramInt == 365) && (!paramString2.equals("")) && (!paramString3.equals("")))
      localArrayList = localStockorderExt.selByList("SEL_NO_DATESS");
    else
      localArrayList = localStockorderExt.selByList("SEL_BY_KEYSS");
    if ((localArrayList != null) && (localArrayList.size() > 0))
      i = localArrayList.size();
    return i;
  }

  public void genStockorder(Buffers paramBuffers)
  {
    this.log.LOG_INFO("进入genStockorder方法...");
    try
    {
      this.queryResult = genStockorder();
    }
    catch (SaasApplicationException localSaasApplicationException)
    {
      this.log.LOG_INFO(localSaasApplicationException.getMessage());
    }
    this.log.LOG_INFO("退出genStockorder方法...");
  }

  public ArrayList genStockorder()
    throws SaasApplicationException
  {
    ArrayList localArrayList1 = new ArrayList();
    ArrayList localArrayList2 = new ArrayList();
    StockorderExt localStockorderExt = new StockorderExt();
    localArrayList1 = localStockorderExt.selByList("SEL_BY_ALL");
    if (localArrayList1 == null)
      return null;
    Iterator localIterator = localArrayList1.iterator();
    while (localIterator.hasNext())
    {
      HashMap localHashMap1 = (HashMap)localIterator.next();
      String str1 = "";
      String str2 = "";
      HashMap localHashMap2 = new HashMap();
      if (localHashMap1.get("stock_id") != null)
        str2 = localHashMap1.get("stock_id").toString();
      if (localHashMap1.get("title") != null)
        str1 = localHashMap1.get("title").toString();
      localHashMap2.put("title", str1);
      localHashMap2.put("stockId", str2);
      localArrayList2.add(localHashMap2);
    }
    return localArrayList2;
  }

  public ArrayList genStockorderLimit(int paramInt)
    throws SaasApplicationException
  {
    ArrayList localArrayList = new ArrayList();
    StockorderExt localStockorderExt = new StockorderExt();
    localArrayList = localStockorderExt.selByList("SEL_BY_LIMIT", 0, paramInt);
    if (localArrayList == null)
      return null;
    return localArrayList;
  }

  public ArrayList genStockEmergency(int paramInt)
    throws SaasApplicationException
  {
    ArrayList localArrayList = new ArrayList();
    StockorderExt localStockorderExt = new StockorderExt();
    localArrayList = localStockorderExt.selByList("SEL_BY_EMERGENCY", 0, paramInt);
    if (localArrayList == null)
      return null;
    return localArrayList;
  }

  public ArrayList genStockByToday(int paramInt)
    throws SaasApplicationException
  {
    ArrayList localArrayList = new ArrayList();
    StockorderExt localStockorderExt = new StockorderExt();
    localArrayList = localStockorderExt.selByList("SEL_BY_TODAY", 0, paramInt);
    if (localArrayList == null)
      return null;
    return localArrayList;
  }

  public String getCustAttachPath(String paramString1, String paramString2)
    throws SaasApplicationException
  {
    Attachinfo localAttachinfo = new Attachinfo();
    String str = localAttachinfo.getAttachPath(paramString1, paramString2, "0");
    return str;
  }

  public void genSpecStockorder(Buffers paramBuffers)
  {
    this.log.LOG_INFO("进入genSpecStockorder方法...");
    String str = paramBuffers.getString("CUST_ID");
    try
    {
      this.queryResult = genSpecStockorder("cust_id");
    }
    catch (SaasApplicationException localSaasApplicationException)
    {
      this.log.LOG_INFO(localSaasApplicationException.getMessage());
    }
    this.log.LOG_INFO("退出genSpecStockorder方法...");
  }

  public ArrayList genSpecStockorder(String paramString)
    throws SaasApplicationException
  {
    ArrayList localArrayList1 = new ArrayList();
    ArrayList localArrayList2 = new ArrayList();
    StockorderExt localStockorderExt = new StockorderExt();
    localStockorderExt.setParam(":VCUST_ID", paramString);
    localArrayList1 = localStockorderExt.selByList("SEL_SPEC_STOCKORDER");
    if (localArrayList1 == null)
      return null;
    Iterator localIterator = localArrayList1.iterator();
    while (localIterator.hasNext())
    {
      HashMap localHashMap1 = (HashMap)localIterator.next();
      String str1 = "";
      String str2 = "";
      HashMap localHashMap2 = new HashMap();
      if (localHashMap1.get("stock_id") != null)
        str2 = localHashMap1.get("stock_id").toString();
      if (localHashMap1.get("title") != null)
        str1 = localHashMap1.get("title").toString();
      try
      {
        str1 = new String(str1.getBytes("ISO8859_1"), "GB2312");
      }
      catch (Exception localException)
      {
        throw new RuntimeException(localException);
      }
      localHashMap2.put("title", str1);
      localHashMap2.put("stockId", str2);
      localArrayList2.add(localHashMap2);
    }
    return localArrayList2;
  }

  public void genPKStockorder(Buffers paramBuffers)
  {
    this.log.LOG_INFO("进入genPKStockorder方法...");
    String str = paramBuffers.getString("STOCK_ID");
    try
    {
      this.queryResult = genPKStockorder("STOCK_ID");
    }
    catch (SaasApplicationException localSaasApplicationException)
    {
      this.log.LOG_INFO(localSaasApplicationException.getMessage());
    }
    this.log.LOG_INFO("退出genPKStockorder方法...");
  }

  public ArrayList genPKStockorder(String paramString)
    throws SaasApplicationException
  {
    ArrayList localArrayList1 = new ArrayList();
    ArrayList localArrayList2 = new ArrayList();
    StockorderExt localStockorderExt = new StockorderExt();
    localStockorderExt.setParam(":VSTOCK_ID", paramString);
    localArrayList1 = localStockorderExt.selByList("SEL_BY_PK");
    if (localArrayList1 == null)
      return null;
    Iterator localIterator = localArrayList1.iterator();
    while (localIterator.hasNext())
    {
      HashMap localHashMap1 = (HashMap)localIterator.next();
      String str1 = "";
      String str2 = "";
      HashMap localHashMap2 = new HashMap();
      if (localHashMap1.get("stock_id") != null)
        str2 = localHashMap1.get("stock_id").toString();
      if (localHashMap1.get("title") != null)
        str1 = localHashMap1.get("title").toString();
      try
      {
        str1 = new String(str1.getBytes("ISO8859_1"), "GB2312");
      }
      catch (Exception localException)
      {
        throw new RuntimeException(localException);
      }
      localHashMap2.put("title", str1);
      localHashMap2.put("stock_id", str2);
      localArrayList2.add(localHashMap2);
    }
    return localArrayList2;
  }

  public ArrayList searchStockorder(String paramString1, String paramString2)
    throws SaasApplicationException
  {
    ArrayList localArrayList = new ArrayList();
    StockorderExt localStockorderExt = new StockorderExt();
    localStockorderExt.setParam(":VTITLE", "%" + paramString1 + "%");
    localStockorderExt.setParam(":VCUST_ID", paramString2);
    localStockorderExt.setParam(":VVALIDITY", "0");
    localArrayList = localStockorderExt.selByList("SEL_BY_SEARCH");
    return localArrayList;
  }

  public void changstockorder(Buffers paramBuffers)
  {
    this.outBuffer = paramBuffers;
    this.inBuffer = paramBuffers;
    this.log.LOG_INFO("进入changstockorder方法...");
    int i = -1;
    try
    {
      StockorderDAO localStockorderDAO = new StockorderDAO();
      localStockorderDAO.setBuying_name(paramBuffers.getString("buying_name"));
      localStockorderDAO.setBuying_desc(paramBuffers.getString("buying_desc"));
      localStockorderDAO.setBuying_site(paramBuffers.getString("buying_site"));
      localStockorderDAO.setBuying_id(paramBuffers.getString("BUYING_ID"));
      localStockorderDAO.setStart_date(paramBuffers.getString("START_DATE"));
      localStockorderDAO.setEnd_date(paramBuffers.getString("END_DATE"));
      i = changstockorder(localStockorderDAO);
    }
    catch (SaasApplicationException localSaasApplicationException)
    {
      this.log.LOG_INFO(localSaasApplicationException.getMessage());
    }
    if (i != 0)
    {
      this.outBuffer.setInt("RESULT_CODE", -1);
      this.outBuffer.setString("RESULT_INFO", "业务处理失败！");
    }
    else
    {
      this.outBuffer.setInt("RESULT_CODE", 0);
      this.outBuffer.setString("RESULT_INFO", "业务处理成功！");
    }
    this.log.LOG_INFO("退出changstockorder方法...");
  }

  public int changstockorder(StockorderDAO paramStockorderDAO)
    throws SaasApplicationException
  {
    StockorderExt localStockorderExt = new StockorderExt();
    localStockorderExt.setParam(":VSTOCK_ID", paramStockorderDAO.getBuying_id());
    localStockorderExt.setParam(":VTITLE", paramStockorderDAO.getBuying_name());
    localStockorderExt.setParam(":VCONTENT", paramStockorderDAO.getBuying_desc());
    localStockorderExt.setParam(":VSTOCK_ADDR", paramStockorderDAO.getBuying_site());
    localStockorderExt.setParam(":VSTART_DATE", paramStockorderDAO.getStart_date());
    localStockorderExt.setParam(":VEND_DATE", paramStockorderDAO.getEnd_date());
    this.tradeQuery.executeBy(localStockorderExt.insBy("UPDATE_BY_STOCKORDER"));
    return 0;
  }

  public void genOneStockorder(Buffers paramBuffers)
  {
    this.log.LOG_INFO("进入genOneStockorder方法...");
    this.outBuffer = paramBuffers;
    String str = paramBuffers.getString("STOCK_ID");
    try
    {
      this.queryResult = genOneStockorder(str);
    }
    catch (SaasApplicationException localSaasApplicationException)
    {
      this.log.LOG_INFO(localSaasApplicationException.getMessage());
    }
    this.log.LOG_INFO("退出genOneStockorder方法...");
  }

  public void autoCheckBuying()
  {
    Statement st = null;
    String str = "update buying set validity=1,check_time=sysdate where validity=0 and auto_state=1";
  
  }

  public void autoCheckSaling()
  {
    Statement st = null;
    String str = "update sales set validity=1,check_time=sysdate where validity=0 and auto_state=1";
  
  }
}

